package com.springboot.demo;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;

import lombok.extern.log4j.Log4j2;

/**
 * springBoot主入口
 *
 * @author supu
 * @create 2018-12-12 11:36
 **/
@Log4j2
@SpringBootApplication
@MapperScan("com.springboot.db.mapper")
public class MainApplication {
    

    public static void main(String[] args) {
//        SpringApplication.run(MainApplication.class, args);


        SpringApplication application = new SpringApplication(MainApplication.class);
//        application.addInitializers(new YamlFileApplicationContextInitializer());
        ConfigurableApplicationContext ctx = application.run(args);

       /* new SpringApplicationBuilder(MainApplication.class)
                .initializers(new YamlFileApplicationContextInitializer()).run(args);*/

       /* ConfigurableApplicationContext ctx =
                application.run(MainApplication.class, args);*/

        ConfigurableEnvironment environment = ctx.getEnvironment();

       /* log.info(environment.getProperty("env"));
        log.info(environment.getProperty("server.port"));
        log.info("webPath:" + environment.getProperty("web.path"));
        log.info(environment.getProperty("custom.name"));
        log.info(environment.getProperty("custom.age"));
        log.info("my.domain:" + environment.getProperty("my.domain"));
        log.info("customHost:" + environment.getProperty("custom.host"));
        log.info("test.host:" + environment.getProperty("test.host"));
        log.info("self.host:" + environment.getProperty("self.host"));*/

    }

  /*  // 加载YML格式自定义配置文件
    @Bean
    public static PropertySourcesPlaceholderConfigurer properties() {
        PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();
        YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean();
        // File引入
//        Resource[] resources = context.getResources("classpath:conf/application*.yaml");
		yaml.setResources(new ClassPathResource("classpath:config/*.yaml"));
//		yaml.setResources(new ClassPathResource("*.yml"));
        configurer.setProperties(yaml.getObject());
        return configurer;
    }*/
}
